package cn.edu.nju.software.gui;

import java.awt.BorderLayout;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import cn.edu.nju.software.net.StudentBean;

public class AddStudentsPanel extends JPanel{
	
	
	
	JLabel userName;
	JTextField userNameValue;
	JLabel password;
	JTextField passwordValue;
	JLabel id ;
	JTextField idValue;
	JLabel name ;
	JTextField nameValue;
	JLabel gender;
	JTextField genderValue;
	JLabel institute;
	JTextField instituteValue;

	
	
	
	
	
	
	
	public AddStudentsPanel(){
	    setLayout(new BorderLayout(1,12));
		userName = new JLabel("userName");
		userNameValue = new JTextField("");
		add(userName);
		add(userNameValue);
		
		password = new JLabel("password");
		passwordValue = new JTextField("");
		add(password);
	    add(passwordValue);
		
		id = new JLabel("id");
		idValue = new JTextField("");
		add(id);
		add(idValue);
		
		name = new JLabel("name");
		nameValue = new JTextField("");
		add(name);
		add(nameValue);
		
		gender = new JLabel("gender");
		genderValue = new JTextField("");
		add(gender);
		add(genderValue);
		
		institute = new JLabel("institute");
		instituteValue = new JTextField("");
		add(institute);
		add(instituteValue);
		
		
		
		
	}
	
	public boolean checkInput(){//ensure there is no empty element
		if(userNameValue.getText().equals("")||
				passwordValue.getText().equals("")||
				idValue.getText().equals("")||
				nameValue.getText().equals("")||
				genderValue.getText().equals("")||
				instituteValue.getText().equals(""))
			return false;
		else
			return true;
	}
	
	public StudentBean getStudent(){
		
		return new StudentBean(
				userNameValue.getText(),
				passwordValue.getText(),
				idValue.getText(),
				nameValue.getText(),
				genderValue.getText(),
				instituteValue.getText());
		
	}
	
	public void clear(){
		userNameValue.setText("");//clear the textFields
		passwordValue.setText("");
		idValue.setText("");
		nameValue.setText("");
		genderValue.setText("");
		instituteValue.setText("");
		
	}



	
}
